package com.example.hzq.food.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.hzq.food.R;
import com.example.hzq.food.bean.FoodBean;
import com.example.hzq.food.bean.OrderBean;
import com.example.hzq.food.model.Model;

import java.util.List;

import retrofit2.Call;

/**
 * Created by hzq on 2017/6/16.
 */

public class ShopScoreadapter extends RecyclerView.Adapter{
    private List<OrderBean> list;
    private Context context;
    private LayoutInflater layoutInflater;
    public ShopScoreadapter(Context context){
        this.context=context;
        layoutInflater=LayoutInflater.from(context);
    }
    public void setList(List<OrderBean>list){
        this.list=list;
        notifyDataSetChanged();
    }
    public class ViewHolder extends RecyclerView.ViewHolder{
        private TextView tv_username,tv_scoretime,tv_foodname,tv_settime,tv_number,tv_price,tv_sum,tv_score;
        public ViewHolder(View itemView) {
            super(itemView);
            tv_foodname=(TextView) itemView.findViewById(R.id.foodname);
            tv_username=(TextView) itemView.findViewById(R.id.username);
            tv_score=(TextView) itemView.findViewById(R.id.score);
            tv_scoretime=(TextView) itemView.findViewById(R.id.scoretime);
            tv_settime=(TextView) itemView.findViewById(R.id.settime);
            tv_number=(TextView) itemView.findViewById(R.id.number);
            tv_sum=(TextView) itemView.findViewById(R.id.sum);
            tv_price=(TextView) itemView.findViewById(R.id.price);
        }
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v=layoutInflater.inflate(R.layout.scoreitem,parent,false);
        return new  ShopScoreadapter.ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder,final int position) {
        OrderBean orderBean=list.get(position);
        if (orderBean == null)
            return;
        ViewHolder viewHolder=(ViewHolder)holder;
      viewHolder.tv_username.setText(orderBean.getUsername());
      viewHolder.tv_scoretime.setText(orderBean.getComment_time());
      viewHolder.tv_foodname.setText(orderBean.getFoodname());
      viewHolder.tv_settime.setText(orderBean.getSuggesttime());
      viewHolder.tv_number.setText(orderBean.getNum()+"");
      viewHolder.tv_price.setText(orderBean.getPrice()+"");
      viewHolder.tv_sum.setText(orderBean.getSum()+"");
      viewHolder.tv_score.setText(orderBean.getContent());
    }

    @Override
    public int getItemCount() {
        if(list==null) return  0;
        else
            return list.size();
    }
}
